package com.ashok.interceptor;

import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.StrutsStatics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ashok.action.LoginAction;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class NoCacheInterceptor extends AbstractInterceptor {
	private static final Logger LOGGER = LoggerFactory
			.getLogger(LoginAction.class);

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		
		LOGGER.info("NO Cache filter called...");
		HttpServletResponse response = (HttpServletResponse) invocation
				.getInvocationContext().get(StrutsStatics.HTTP_RESPONSE);
		//to clear browser cache
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Cache-Control","no-store");
		response.setHeader("Pragma", "no-cache");
		response.setDateHeader("Expires", 0);

		
		return invocation.invoke();
	}
}
